#ifndef MYLINE_H
#define MYLINE_H

#include <QGraphicsItem>

class MyLine : public QObject,public QGraphicsItem		//  双继承
{
    Q_OBJECT
public:
    MyLine();				// 自动生成的构造函数

    QPointF mspt,mept;			// 定义了直线的两个端点

    // QGraphicsItem interface
public:
    QRectF boundingRect() const override;
    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;

    void DrawSnapRect(QPainter *painter, QPointF cpt);

    // QGraphicsItem interface
protected:
    void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
    void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;

    // QGraphicsItem interface
public:
    QPainterPath shape() const override;
};

#endif // MYLINE_H
